package com.xiaoshuidi.cloud.module.member.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum QuestionTypeEnum {
    SINGLE_CHOICE(1, "单选题"),
    MULTIPLE_CHOICE(2, "多选题"),
    FILL_BLANKS (3, "填空题"),
    SINGLE_FILL_BLANK (4, "单选填空题"),
    PICTURE(5, "图片题");
    private Integer code;
    private String name;

    public static String getNameByCode(Integer code) {
        QuestionTypeEnum questionTypeEnum = Arrays.stream(QuestionTypeEnum.values()).filter(p -> p.code.intValue() == code.intValue()).findFirst().orElse(null);
        Assert.isTrue(questionTypeEnum != null, "QuestionTypeEnum:{}不存在", code);
        return questionTypeEnum.getName();
    }
}
